package com.xiaoyun.vo;

import com.xiaoyun.constant.ErrorCode;
import com.xiaoyun.dao.MerchantsDao;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * 投放的优惠券对象定义
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel
public class PassTemplate {

    private Integer id;
    private String title;
    //摘要
    private String summary;
    private String desc;
    //最大个数限制
    private Long limit;
    //优惠券是否 Token，用于商户核销
    private Boolean hasToken;
    //优惠券背景色
    private Integer background;
    //优惠券开始时间
    private Date start;
    //优惠券结束时间
    private Date end;

    /**
     * 校验优惠券对象的有效性
     *
     * @param merchantsDao
     * @return
     */
    public ErrorCode validate(MerchantsDao merchantsDao) {
        if (null == merchantsDao.findById(id)) {
            return ErrorCode.MERCHANTS_NOT_EXIST;
        }
        return ErrorCode.SUCCESS;
    }


}
